﻿using System.Threading.Tasks;
using JetBrains.Annotations;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;

namespace MetroManagement
{
    /// <summary>
    /// 乘车卡管理类
    /// </summary>
    public class CardManager : DomainService
    {
        private readonly IRepository<Card, int> _cardRepository;

        public CardManager(
            IRepository<Card, int> cardRepository)
        {
            _cardRepository = cardRepository;
        }

        public async Task<Card> CreateAsync(
            int userId,
            [NotNull] string userName,
            [NotNull] string idCard,
            [NotNull] string phonenumber,
            [NotNull] string cardNum)
        {
            return await _cardRepository.InsertAsync(
                new Card(
                    userId,
                    userName,
                    idCard,
                    phonenumber,
                    cardNum
                )
            );
        }
    }
}